﻿using System;
using System.Collections.Generic;
using SharpStockLib.Data;

namespace SharpBackTestLib.Indicators
{
    public enum EMovingAverageValueType
    {
        Close,
        Open,
        High,
        Low,
        HLC3,
        OHLC4
    }

    public class NotEnoughDataException : Exception
    {
        public NotEnoughDataException(string message) : base(message)
        {
        }
    }

    /// <summary>
    /// Base class to implement a moving average indicator. Contains several members that will be useful to all classes that extend it.
    /// </summary>
    public abstract class MovingAverageBase : IIndicator
    {
        // LIFO buffer to store latest N values
        protected Queue<IData> _dataBuffer;
        protected double _value;

        public EMovingAverageValueType Type { get; set; }
        public int Length { get; protected set; }

        public abstract double? GetValue();

        #region IIndicator Members

        /// <summary>
        /// Adds data into the buffer.
        /// </summary>
        /// <param name="newData">The new data to add</param>
        public abstract void OnNewData(IData newData);

        #endregion
    }
}
